<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>

<!DOCTYPE html>
<html>
<head>
</head>
  <title>项目追踪</title>
  <style type="text/css">
	.layui-form-item {
	    margin-bottom: 0px;
	    clear: both;
	    *zoom: 1;
	}

	.layui-form-label{width: 90px;}
  </style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <!-- 查询区域  -->
      <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
       	<div class="layui-form-item">
       		<div class="layui-inline">
            	<label class="layui-form-label">项目阶段</label>
            	<div class="layui-input-inline">
              		<select name="proStage">
		              	<option value="0">全部</option>
		              	<option value="1">预立项</option>
						<option value="2">立项策划</option>
						<option value="3">立项</option>
		              	<option value="4">营销策划</option>
		              	<option value="5">资格预审</option>
		              	<option value="6">招标文件分析</option>
		              	<option value="7">标书策划</option>
		              	<option value="8">投标决策</option>
		              	<option value="9">投标保证金申请</option>
		              	<option value="10">项目投标</option>
		              	<option value="11">交底</option>
              		</select>
            	</div>
            </div>


			<div class="layui-inline">
				<label class="layui-form-label">日期选择</label>
				<div class="layui-input-inline">
					<input type="text" id="sent-layyear-start-mon" name="startTrackDate" readonly placeholder="请选择创建日期" autocomplete="off" class="layui-input">
				</div>
			</div>
<%--			<div class="layui-inline">--%>
<%--	         	<label class="layui-form-label">追踪日期</label>--%>
<%--	         	<div class="layui-input-inline">--%>
<%--	           		<input type="text" class="layui-input" id="sent-layyear-start-mon" name="startTrackDate" readonly placeholder="开始日期">--%>
<%--	         	</div>--%>
<%--   			</div>--%>
			 <div class="layui-inline">
                <label class="layui-form-label">状态</label>
            <div class="layui-input-inline">
              <select name="trackStatus">
                  <option value="">状态</option>
                  <option value="0">跟踪中</option>
                  <option value="1">已结束</option>
              </select>
          </div>
          </div>
      	<shiro:hasPermission name="MKT_PRO_TRACK">
      	<div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-proPlot-search">
              	<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
            </button>
            <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-reset">
              	<i class="layui-icon layui-icon-fonts-clear  layuiadmin-button-btn"></i>重置
            </button>
      	</div>
      	</shiro:hasPermission>
    </div>
  </div>


  	  <!-- 按钮区域  -->
      <div class="layui-card-body">
      	<div style="padding-bottom: 10px;">
          	<shiro:hasPermission name="ADD_PRO_TRACK">
          		<button class="layui-btn layuiadmin-btn-admin " data-type="add">
          	 		<i class="layui-icon layui-icon-add-1 layuiadmin-button-btn"></i>新建
          		</button>
          	</shiro:hasPermission>
          	<shiro:hasPermission name="EXPORT_PRO_TRACK">
          		<button class="layui-btn layuiadmin-btn-admin " data-type="export" onclick="exportList();">
          	 		<i class="layui-icon layui-icon-export layuiadmin-button-btn"></i>导出
          		</button>
          </shiro:hasPermission>
        </div>
        <!-- 数据表单 -->
       <table id="LAY-proPlot-create-manage" lay-filter="LAY-proPlot-create-manage"></table>

 	</div>
  </div>

  </div>

  <script>
  	layui.config({
    	base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index' //主入口模块
  	}).use(['index', 'table', 'set', 'transfer', 'laydate'], function(){
    	var $ = layui.$
    	,form = layui.form
    	,table = layui.table
    	,element = layui.element
    	,laydate = layui.laydate;
    	//tab重新渲染宽度
    	element.on('tab(component-tabs-brief)', function(obj){
    		$(window).resize();
    	});

		//日期
		laydate.render({
			elem: '#startTrackDate'
		});
		laydate.render({
			elem: '#sent-layyear-start-mon'
		});
  	    // //开始日期
  	    // var insStart = laydate.render({
  	    //   elem: '#sent-laydate-start'
  	    //   ,done: function(value, date){
  	    //     //更新结束日期的最小日期
  	    //     insEnd.config.min = lay.extend({}, date, {
  	    //       month: date.month - 1
  	    //     });
		  //
  	    //     //自动弹出结束日期的选择器
  	    //    insEnd.config.elem[0].focus();
  	    //   }
  	    // });
		  //
  	    // //结束日期
  	    // var insEnd = laydate.render({
  	    //   elem: '#sent-laydate-end'
  	    //   ,done: function(value, date){
  	    //     //更新开始日期的最大日期
  	    //     insStart.config.max = lay.extend({}, date, {
  	    //       month: date.month - 1
  	    //     });
  	    //   }
  	    // });

 		// 正则校验
    	form.verify({
    		//验证汉字
    	    CHS: [
    	    	/^[\u0391-\uFFE5]+$/
    	    	,'只能输入汉字'
    	  	],
	    	//大于0的正整数
		  	intNumber:[
				/^[1-9]\d*$/
				,'请输入正确的数字'
		  	]
		});

    	// //开始年月
  	  //   var yearStart = laydate.render({
  	  //     elem: '#sent-layyear-start-mon'
  	  //     ,type: 'date'
  	  //     ,format:'yyyy-MM-dd'
  	  //     ,done: function(value, date){
  	  //       //更新结束日期的最小日期
  	  //       yearEnd.config.min = lay.extend({}, date, {
  	  //         month: date.month - 1
  	  //       });
		//
  	  //       //自动弹出结束日期的选择器
  	  //      yearEnd.config.elem[0].focus();
  	  //     }
  	  //   });
		//
  	  //   //结束年月
  	  //   var yearEnd = laydate.render({
  	  //     elem: '#sent-layyear-end-mon'
  	  //     ,type: 'date'
  	  // 	  ,format:'yyyy-MM-dd'
  	  //     ,done: function(value, date){
  	  //       //更新开始日期的最大日期
  	  //       yearStart.config.max = lay.extend({}, date, {
  	  //         month: date.month - 1
  	  //       });
  	  //     }
  	  //   });

	// 表单
	table.render({
  		elem: '#LAY-proPlot-create-manage'
  		,url: basePath + '/proTrack/queryDataByCondition' //请求数据接口  ?hrStaffApplyId=${SESSION_KEY_USER_DETAIL.hrStaffId }
  		,cols: [[
    		{type: 'checkbox', fixed: 'left'}
    		,{field: 'proCode', title: '项目编号', width: 160,align:'center'}
			,{field: 'compName', title: '区域公司', width: 160,align:'center'}
    		,{field: 'proName', title: '项目名称', width: 280,align:'center'}
			,{field: 'addTime', title: '最新跟踪时间', width: 120,align:'center', templet: function(d){
					return layui.util.toDateString(d.addTime,"yyyy-MM-dd");
				}
			}
    		,{field: 'pointsCount', title: '难点、卡点数量', width: 123,align:'center'}

			,{field: 'trackCount', title: '跟踪次数',width: 300,align:'center'}
			,{field: 'tomorrowPlan', title: '最新进展',width: 140,align:'center'}
    		,{field: 'isTrack', width: 150,title: '跟踪状态',align:'center',templet:function (d) {
					if(d.isTrack=='0'){
						return '跟踪中';
					}else if(d.isTrack=='1'){
						return '已结束';
					}else{
						return '';
					}

				}}


			/*,{field: 'staffName', title: '申请人',width: 123,align:'center'}
            ,{field: 'addTime', title: '创建时间', width: 170,align:'center', templet: function(d){
                  return layui.util.toDateString(d.addTime,"yyyy-MM-dd HH:mm:ss");
                  }
             }*/
    		,{title: '操作', width: 160, align:'center', fixed: 'right',align:'center', templet: function(d){
	  	  				var optStr ="";
	  	  				<shiro:hasPermission name="VIEW_PRO_TRACK">
  	  						optStr += '<a class="layui-btn layui-btn-xs" lay-event="view"><i class="layui-icon layui-icon-form"></i>详情 </a> ';
  	  	  				</shiro:hasPermission>
	  	  	  			<shiro:hasPermission name="COPY_PRO_TRACK">
		  					/* optStr += '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="copy"><i class="layui-icon layui-icon-release"></i>复制单据</a>'; */
		  				</shiro:hasPermission>
		  				/*if(d.processStatus == '10'){
      	  					optStr += '<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>';
	  	  	  			}*/
			  		  	return optStr;
        			}
        		}
      			]]
      		,page: true
      		,limit: 10
    	});

	<shiro:hasPermission name="MKT_PRO_TRACK">
    	//监听搜索
    	form.on('submit(LAY-proPlot-search)', function(data){
    		var tabId = $(".layui-tab-title .layui-this").attr("lay-id");
   			//执行重载
	      	table.reload('LAY-proPlot-create-manage', {page: {curr: 1},
	        	where: trimData(data)
	      	});
    	});
    	//重置清空
	    form.on('submit(LAY-user-back-reset)', function(data){
	    	reset_form('query-form');
	    	//额外处理select
			$("#query-form-state").val('');
			form.render();
	    });
	</shiro:hasPermission>

	// 监听操作列
	table.on('tool(LAY-proPlot-create-manage)', function(obj){
  			var data = obj.data;
 			if(obj.event === 'view'){
	       		parent.layui.index.openTabsPage(basePath + '/proTrack/detailNew?id=' + data.id + '&proCode=' + data.proCode,'项目追踪 > 详情');
	   		}else if(obj.event === 'del'){
      			layer.confirm('确定要删除？',{icon:3, title :'提示'}, function(index){
          			$.ajax({
            			type : 'post',
    						url : basePath + '/flowProcess/logicDel',
    						data : {
    		    				"processId" :data.processId
    		    			},//数据，这里使用的是Json格式进行传输
    						success:function(result){
    							if(result){
        							table.reload('LAY-proPlot-create-manage'); //数据刷新
        							layer.close(index); //关闭弹层
    							}else{
    								layer.msg('数据通信异常~',{icon: 0});
    			  				}
    						}
        			});
       			})
       		}
    	});

	// 按钮事件
	var active = {
	  add: function(){
		  parent.layui.index.openTabsPage(basePath + '/proTrack/add','项目追踪 > 新建');
	  }
	}
	// data-type事件
	$('.layui-btn.layuiadmin-btn-admin').on('click', function(){
	  var type = $(this).data('type');
	  active[type] ? active[type].call(this) : '';
	});

  });

  	//导出excel
   	function exportList() {
   		layer.msg("暂未上线，敬请期待~",{icon: 1});
	}
  </script>
</body>
</html>
